package com.zf.service;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.zf.dao.domain.MockInfoDao;

public class DataProviderService {
	
	public static String LOAD_DATA;
	
	public static List<MockInfoDao> MOCK_INFOS;
	
	static{
		InputStream in = null;
		ByteArrayOutputStream bos = null;
		try {
			in = MockInfoService.class.getClassLoader().getResourceAsStream("data.json");
			bos = new ByteArrayOutputStream();
			int read;
			while((read= in.read())!=-1){
				bos.write(read);
				bos.flush();
			}
			LOAD_DATA = bos.toString("UTF-8");
			MOCK_INFOS = JSON.parseArray(LOAD_DATA, MockInfoDao.class);
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try{
				if(in != null){
					in.close();
				}
				if(bos != null){
					bos.close();
				}
			}catch(Exception e){
				e.printStackTrace();
			}
		}
	}
	
}
